package entity

import "gitee.com/nanakura/h-scraper/internal/model"

type SourceEntity struct {
	Name             string `json:"name" sql:"name"`
	Url              string `json:"url" sql:"url"`
	TitleUrl         string `json:"title_url" sql:"title_url"`
	TitleText        string `json:"title_text" sql:"title_text"`
	PaginationActive string `json:"pagination_active" sql:"pagination_active"`
	PaginationUrl    string `json:"pagination_url" sql:"pagination_url"`
	PaginationText   string `json:"pagination_text" sql:"pagination_text"`
	CategoryUrl      string `json:"category_url" sql:"category_url"`
	CategoryText     string `json:"category_text" sql:"category_text"`
	ImgUrl           string `json:"img_url" sql:"img_url"`
	Text             string `json:"text" sql:"text"`
}

func (receiver SourceEntity) TableName() string {
	return "source"
}

func MapSourceModelToSourceEntity(model model.SourceModel) SourceEntity {
	return SourceEntity{
		Name:             model.Name,
		Url:              model.Url,
		TitleUrl:         model.TitleTableSelectors.TitleUrl,
		TitleText:        model.TitleTableSelectors.TitleText,
		PaginationActive: model.TitleTableSelectors.PaginationActive,
		PaginationText:   model.TitleTableSelectors.PaginationText,
		PaginationUrl:    model.TitleTableSelectors.PaginationUrl,
		CategoryText:     model.TitleTableSelectors.CategoryText,
		CategoryUrl:      model.TitleTableSelectors.CategoryUrl,
		ImgUrl:           model.ContentSelectors.ImgUrl,
		Text:             model.ContentSelectors.Text,
	}
}
